﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using Fluid.Controls;
using TouchRC.Classes;
using Microsoft.Drawing;
using System.Drawing;
using TouchRC.Logic;

namespace TouchRC.Custom_Controls
{
    public enum RemoteControlSpecial
    {
        RemoveRemote
    }

    public class Skip
    {
    }

    public class RemoteControlButton : TouchButton
    {
        #region Private Members

        private int m_LandscapePos;
        private int m_PortraitPos;
        private object m_Enum;

        #endregion

        #region Public Accessors

        public int LandscapePos { get { return m_LandscapePos; } }
        public int PortraitPos { get { return m_PortraitPos; } }
        public object Enum { get { return m_Enum; } }

        #endregion

        public RemoteControlButton(object buttonEnum, IImage image)
            : base()
        {
            m_Enum = buttonEnum;
            Image = image;
        }

        public RemoteControlButton(object buttonEnum, IImage image, int landscapePos, int portraitPos)
            : base()
        {
            m_Enum = buttonEnum;
            Image = image;
            m_LandscapePos = landscapePos;
            m_PortraitPos = portraitPos;
        }

        public RemoteControlButton(object buttonEnum, int landscapePos, int portraitPos)
            : base()
        {
            m_Enum = buttonEnum;
            m_LandscapePos = landscapePos;
            m_PortraitPos = portraitPos;
        }

        public override bool OnClick(PointEventArgs e)
        {
            bool handled = false;

            if (m_Enum is RemoteCommands.GoToPlaces)
            {
                new VmcControllerRemote(MainMenuPanel.CurrentComputer).GoToScreen((RemoteCommands.GoToPlaces)m_Enum);
                handled = true;
            }
            else if (m_Enum is RemoteCommands.ButtonCommands)
            {
                new VmcControllerRemote(MainMenuPanel.CurrentComputer).PressButton((RemoteCommands.ButtonCommands)m_Enum);
                handled = true;
            }
            else if (m_Enum is RemoteCommands.VolumeOptions)
            {
                new VmcControllerRemote(MainMenuPanel.CurrentComputer).ChangeVolume((RemoteCommands.VolumeOptions)m_Enum);
                handled = true;
            }
            else if (m_Enum is RemoteControlSpecial)
            {
                if ((RemoteControlSpecial)m_Enum == RemoteControlSpecial.RemoveRemote)
                {
                    KeyboardPanel.Instance.HideKeyboard();
                    //panel.ShowKeyboard();
                }
                handled = true;
            }

            if (!handled)
            {
                MessageDialog.Show(string.Format("Not Implemented {0} Yet"), "Ok", null);
            }
            return false;
        }

        public override string ToString()
        {
            return "L" + m_LandscapePos.ToString("00") + "_P" + m_PortraitPos.ToString("00") + "_" + m_Enum.ToString(); 
        }
    }
}
